package es.unileon.is.finalproyect.themes;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.nilo.plaf.nimrod.NimRODLookAndFeel;
import com.nilo.plaf.nimrod.NimRODTheme;


public class Themes {
	
	private Component container;
	private static JMenu menuTheme;
	
	private Themes( JMenu menu, Component containerEntrada){

		menuTheme = menu;
		container = containerEntrada;
		
		JMenuItem itemTheme = new JMenuItem("Linux/Windows Theme");
		JMenuItem itemTheme1 = new JMenuItem("Red White Theme");
		JMenuItem itemTheme2 = new JMenuItem("Soft Blue Theme");
		JMenuItem itemTheme3 = new JMenuItem("old Theme");
		JMenuItem itemTheme4 = new JMenuItem("Classic Gray Theme");
		JMenuItem itemTheme5 = new JMenuItem("Black Theme");
		JMenuItem itemTheme6 = new JMenuItem("Dark Gray-Blue theme");
		
		menuTheme.add(itemTheme);
		menuTheme.add(itemTheme1);
		menuTheme.add(itemTheme2);
		menuTheme.add(itemTheme3);
		menuTheme.add(itemTheme4);
		menuTheme.add(itemTheme5);
		menuTheme.add(itemTheme6);
		
		itemTheme.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				String so = System.getProperty("os.name");
				if("Linux".equals(so))
					ChangeTheme.changeTheme("com.sun.java.swing.plaf.gtk.GTKLookAndFeel", container);
				else
					ChangeTheme.changeTheme("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", container);
			}
		});
		
		itemTheme1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				NimRODTheme nt = new NimRODTheme("themes/NimRODThemeFile.theme");
				NimRODLookAndFeel nf = new NimRODLookAndFeel();
				nf.setCurrentTheme( nt);
				
				try {
					UIManager.setLookAndFeel( nf);
					
				} catch (UnsupportedLookAndFeelException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				ChangeTheme.changeTheme(UIManager.getCrossPlatformLookAndFeelClassName(), container);
				
				//estoy probando a meter los creados por mi
			}
		});
		
		itemTheme2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				ChangeTheme.changeTheme("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel", container);
			}
		});
		
		itemTheme3.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				ChangeTheme.changeTheme("com.sun.java.swing.plaf.motif.MotifLookAndFeel", container);
			}
		});
		
		itemTheme4.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				NimRODTheme nt = new NimRODTheme("themes/NimRODThemeFile2.theme");
				NimRODLookAndFeel nf = new NimRODLookAndFeel();
				nf.setCurrentTheme( nt);
				
				try {
					UIManager.setLookAndFeel( nf);
					
				} catch (UnsupportedLookAndFeelException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				ChangeTheme.changeTheme(UIManager.getCrossPlatformLookAndFeelClassName(), container);
				
				//estoy probando a meter los creados por mi
			}
		});

		itemTheme5.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				NimRODTheme nt = new NimRODTheme("themes/NimRODThemeFile3.theme");
				NimRODLookAndFeel nf = new NimRODLookAndFeel();
				nf.setCurrentTheme( nt);
				
				try {
					UIManager.setLookAndFeel( nf);
					
				} catch (UnsupportedLookAndFeelException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				ChangeTheme.changeTheme(UIManager.getCrossPlatformLookAndFeelClassName(), container);
				
				//estoy probando a meter los creados por mi
			}
		});
		
		itemTheme6.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				NimRODTheme nt = new NimRODTheme("themes/NimRODThemeFile4.theme");
				NimRODLookAndFeel nf = new NimRODLookAndFeel();
				nf.setCurrentTheme( nt);
				
				try {
					UIManager.setLookAndFeel( nf);
					
				} catch (UnsupportedLookAndFeelException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				ChangeTheme.changeTheme(UIManager.getCrossPlatformLookAndFeelClassName(), container);
				
				//estoy probando a meter los creados por mi
			}
		});	

	}
	
	public static JMenu showNewTheme(JMenu menu, Component container){
		new Themes(menu, container);
		return menuTheme;
	}

}
